package com.cxyzy.demo.utils

import android.content.Context
import com.cxyzy.demo.db.AppDatabase
import com.cxyzy.demo.db.repository.UserRepository
import com.cxyzy.demo.viewmodels.UserViewModelFactory

/**
 * Static methods used to inject classes needed for various Activities and Fragments.
 */
object InjectorUtils {

    private fun getUserRepository(context: Context): UserRepository {
        return UserRepository.getInstance(
                AppDatabase.getInstance(context.applicationContext).userDao())
    }

    fun provideUserViewModelFactory(
        context: Context
    ): UserViewModelFactory {
        val repository = getUserRepository(context)
        return UserViewModelFactory(repository)
    }

}
